home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / proc / machTypeSpur.c < prev    next >
C/C++ Source or Header  |  1991-03-16  |  2KB  |  87 lines

  1. /* 
  2.  * machTypeSpur.c --
  3.  *
  4.  *    Contains the machine specific routine for determining if
  5.  *      a file is an object file for spur.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/attcmds/file/RCS/machTypeSpur.c,v 1.2 90/02/07 23:06:50 shirriff Exp Locker: shirriff $";
  19. #endif /* not lint */
  20.  
  21. #include <spur.md/sys/exec.h>
  22. #include <spur.md/a.out.h>
  23. #include "file.h"
  24.  
  25.  
  26. /*
  27.  *----------------------------------------------------------------------
  28.  *
  29.  * machTypeSpur --
  30.  *
  31.  *    Determine if the file is a spur-specific file type.
  32.  *
  33.  * Results:
  34.  *    If successful, return the name of the machine.  Otherwise
  35.  *      return NULL.
  36.  *
  37.  * Side effects:
  38.  *    Modifies the `magic' number.
  39.  *
  40.  *----------------------------------------------------------------------
  41.  */
  42.  
  43. char *
  44. machTypeSpur(bufferSize, buffer, magic, syms, other)
  45.     int        bufferSize;    /* size of buffer */
  46.     char    *buffer;    /* buffer containing header */
  47.     int         *magic;         /* pointer to magic number */
  48.     int         *syms;          /* pointer to symbols */
  49.     char    **other;    /* other information to return */
  50. {
  51.  
  52.  
  53.     struct exec        *header;
  54.     char        swappedHeader[sizeof(*header) * 2];
  55.     int            swappedSize = sizeof(swappedHeader);
  56.     int            status;
  57.  
  58.     *other = "";
  59.  
  60.     if (bufferSize < sizeof(struct exec)) {
  61.     return NULL;
  62.     }
  63.     header = (struct exec *) buffer;
  64.     if (!N_BADMAG(*header)) {
  65.     *magic = header->a_magic;
  66.     *syms = header->a_syms;
  67.     return "spur";
  68.     }
  69.     if (FMT_SPUR_FORMAT != hostFmt) {
  70.     status = Fmt_Convert("{w12}", FMT_SPUR_FORMAT, &bufferSize, buffer,
  71.             hostFmt, &swappedSize, swappedHeader);
  72.     if (status) {
  73. #ifndef KERNEL
  74.         fprintf(stderr, "Fmt_Convert returned %d.\n", status);
  75. #endif
  76.         return NULL;
  77.     }
  78.     header = (struct exec *) swappedHeader;
  79.     if (!N_BADMAG(*header)) {
  80.         *magic = header->a_magic;
  81.         *syms = header->a_syms;
  82.         return "spur";
  83.     }
  84.     }
  85.     return NULL;
  86. }
  87.